const BehaviorAll = require("../../../behaviors/behavior_all.js");
const ServiceUser = require("../../../service/service_user.js");
const ServiceOrder = require("../../../service/service_order.js");

Component({
  /**
   * behaviors
   */
  behaviors: [BehaviorAll],
  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null,
    orderInfo: {paying:0, sending:0, sended:0}
  },

  methods: {
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
      const _this = this;
      this.data.promise = new Promise(function (resolve, reject) {
        ServiceUser.getInfo(function (data) {
          resolve();
          _this.setData({ userInfo: data });
        });
      })
      //
      ServiceOrder.gainOrderStatistics(function(data){
        _this.setData({ orderInfo: data });
      });
    },

    onReady: function () {
      this.data.promise.then(function () {
        wx.hideLoading();
      });
    }
  }

})